package com.student.manage.entity.model;

import com.student.manage.entity.LoginToken;
import com.student.manage.entity.User;

import java.util.Map;

public class LoginResult {
    private boolean success;
    private LoginToken loginToken;
    private User user;

    private Map<String, String> errors;

    public LoginResult(boolean success, LoginToken loginToken, User user, Map<String, String> errors) {
        this.success = success;
        this.loginToken = loginToken;
        this.user = user;
        this.errors = errors;
    }

    public static LoginResult success(LoginToken loginToken, User user) {
        return new LoginResult(true, loginToken, user, null);
    }

    public static LoginResult fail(User user, Map<String, String> errors) {
        return new LoginResult(false, null, user, errors);
    }

    public LoginToken getLoginToken() {
        return loginToken;
    }

    public User getUser() {
        return user;
    }

    public boolean isSuccess() {
        return success;
    }

    public Map<String, String> getErrors() {
        return errors;
    }
}
